/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import dal.*;
import dto.LoaiDeThiDTO;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.util.ArrayList;

/**
 *
 * @author Stanley
 */
public class ModuleExamController {

    public ArrayList getAllLoaiDeThi() {
        LoaiDeThiDAO dao = new LoaiDeThiDAO();
        return dao.getAllLoaiDeThi();
    }

    public ResultSet getDeThi(int maLDT) {
        DeThiDAO dao = new DeThiDAO();
        return dao.getDeThi(maLDT);
    }

    public boolean insertDeThi(String maDT, String maLDT) {
        DeThiDAO dao = new DeThiDAO();
        return dao.insertDeThi(maDT, maLDT);
    }

    public int getDeThiLonNhat() {
        DeThiDAO dao = new DeThiDAO();
        return dao.getDeThiLonNhat();
    }

    public ResultSet getLoaiDeThiByMaDT(String maDT) {
        DeThiDAO dao = new DeThiDAO();
        return dao.getLoaiDeThiByMaDT(maDT);
    }

    public int getLoaiDeThiLonNhat() {
        LoaiDeThiDAO dao = new LoaiDeThiDAO();
        return dao.getLoaiDeThiLonNhat();
    }

    public LoaiDeThiDTO getLoaiDeThi(String maLDT) {
        LoaiDeThiDAO dao = new LoaiDeThiDAO();
        return dao.getLoaiDeThi(maLDT);
    }

    public ResultSet getChiTietDeThi(String maDT) {
        DeThiDAO dao = new DeThiDAO();
        return dao.getChiTietDeThi(maDT);
    }

    public int getSoLuongBaiThi(int maDT, String maTS) {
        BaiThiDAO dao = new BaiThiDAO();
        return dao.getSoLuongBaiThi(maDT, maTS);
    }

    public ResultSet getBaiThi(String maBT) {
        BaiThiDAO dao = new BaiThiDAO();
        return dao.getBaiThi(maBT);
    }

    public ResultSet getBaiThi(String maDT, int maTS, String time) {
        BaiThiDAO dao = new BaiThiDAO();
        return dao.getBaiThi(maDT, maTS, time);
    }

    public ResultSet getBaiThiSauKhiThi(String maBT) {
        BaiThiDAO dao = new BaiThiDAO();
        return dao.getBaiThiSauKhiThi(maBT);
    }

    public ResultSet getChiTietBaiThi(String maBT) {
        BaiThiDAO dao = new BaiThiDAO();
        return dao.getChiTietBaiThi(maBT);
    }

    public boolean insertBaiThi(String maDT, int maTS, String time) {
        BaiThiDAO dao = new BaiThiDAO();
        return dao.insertBaiThi(maDT, maTS, time);
    }

    public int getSoLuongCauHoiDe() {
        CauHoiDAO dao = new CauHoiDAO();
        return dao.getSoLuongCauHoi("dokho = 1");
    }

    public int getSoLuongCauHoiTB() {
        CauHoiDAO dao = new CauHoiDAO();
        return dao.getSoLuongCauHoi("dokho = 2");
    }

    public int getSoLuongCauHoiKho() {
        CauHoiDAO dao = new CauHoiDAO();
        return dao.getSoLuongCauHoi("dokho = 3");
    }

    public ArrayList getDSCauHoiDe(int limit) {
        CauHoiDAO dao = new CauHoiDAO();
        return dao.getDSCauHoi("dokho = 1", limit);
    }

    public ArrayList getDSCauHoiTB(int limit) {
        CauHoiDAO dao = new CauHoiDAO();
        return dao.getDSCauHoi("dokho = 2", limit);
    }

    public ArrayList getDSCauHoiKho(int limit) {
        CauHoiDAO dao = new CauHoiDAO();
        return dao.getDSCauHoi("dokho = 3", limit);
    }

    public boolean themCauHoiVaoDeThi(String maDT, String maCH, int thutu) {
        DeThiDAO dao = new DeThiDAO();
        return dao.themCauHoiVaoDeThi(maDT, maCH, thutu);
    }

    public boolean themLoaiDeThi(String maLDT, String tenloai, String thoigian, String socaude,
            String socautb, String socaukho) {
//        query.executeUpdate("insert into loaidethi (maLDT, tenloai, thoigian, socaude, socautb, socaukho) values ( "
//                    + maLDT + " , '" + tenloai + "' , " + thoigian + " , " + socaude + " , " + socautb + " , " + socaukho + " )");
        LoaiDeThiDTO info = new LoaiDeThiDTO(
                Integer.parseInt(maLDT),
                tenloai, Integer.parseInt(thoigian),
                Integer.parseInt(socaude),
                Integer.parseInt(socaukho),
                Integer.parseInt(socautb));

        LoaiDeThiDAO dao = new LoaiDeThiDAO();
        return dao.themLoaiDeThi(info);
    }

    public boolean themChiTietBaiThi(String maBT, String cauhoi, String luachon) {
        ChiTietBaiThiDAO dao = new ChiTietBaiThiDAO();
        return dao.themChiTietBaiThi(maBT, cauhoi, luachon);
    }

    public int getThoiGianQuyDinhCuaBaiThi(String maBT) {
        BaiThiDAO dao = new BaiThiDAO();
        return dao.getThoiGianQuyDinh(maBT);
    }

    public Timestamp getThoiGianBatDauLamBai(String maBT) {
        BaiThiDAO dao = new BaiThiDAO();
        return dao.getThoiGianBatDau(maBT);
    }
    
    public boolean updateThoiGianKetThuLamBai(String maBT, String thoigiankt, float diem){
        BaiThiDAO dao = new BaiThiDAO();
        return dao.updateThoiGianKetThuLamBai(maBT, thoigiankt, diem);
    }
}
